<?php
/**
 *
 * @author Tongle Xu <xutongle@gmail.com> 2013-9-16
 * @copyright Copyright (c) 2003-2103 tintsoft.com
 * @license http://www.tintsoft.com
 * @version $Id$
 */
class Loader {
	private static $instances = array ();

	/**
	 * 加载Session
	 */
	public static function session() {
		if (! isset ( self::$instances ['session'] )) {
			// 加载Session配置文件
			$options = C ( 'session' );
			if (function_exists ( 'ini_set' )) @ini_set ( 'session.gc_maxlifetime', $options ['maxlifetime'] );
			session_cache_expire ( $options ['cache_expire'] );
			session_set_cookie_params ( $options ['cookie_lifetime'], $options ['cookie_path'], $options ['cookie_domain'] );
			$class = 'Session_' . ucfirst ( $options ['class'] );
			Kernel::createComponent ( $options );
			if (isset ( $_GET ['SID'] ) && ! empty ( $_GET ['SID'] )) session_id ( trim ( $_GET ['SID'] ) );
			session_start ();
			define ( 'SID', session_id () );
			self::$instances ['session'] = true;
		}
		return self::$instances ['session'];
	}
}